package stone.ast;

import java.util.List;

import ASTInterpreter.ArrayEnv;
import ASTInterpreter.Environment;
import stone.Symbols;

public class ParameterList extends ASTList {

	protected int[] offsets = null;

	public ParameterList(List<ASTree> list) {
		super(list);
	}

	public String name(int i) {
		return ((ASTLeaf)child(i)).token.getText();
	}
	
	public int size() {
		return numChildren();
	}

	/*
	public void eval(Environment env, int index, Object value) {
		(env).putNew(name(index), value);
	}
	*/

	public void lookup(Symbols symbols) {
		int s = size();
		offsets = new int[s];
		for (int i = 0; i < s; ++s) {
			offsets[i] = symbols.putNew(name(i));
		}
	}
	
	public void eval(Environment env, int index, Object value) {
		((ArrayEnv)env).put(0, offsets[index], value);
	}
}
